package com.insigma.business.qrcode.soldier._provider.impl;

import com.google.common.collect.Lists;
import com.insigma.business.qrcode.common.service.SequenceGenerator;
import com.insigma.business.qrcode.common.vo.BaseDeleteRequest;
import com.insigma.business.qrcode.soldier.dao.SoldierOuterLoginAccountDao;
import com.insigma.business.qrcode.soldier.dto.SoldierOuterLoginAccountDTO;
import com.insigma.business.qrcode.soldier.entity.SoldierOuterLoginAccountDO;
import com.insigma.business.qrcode.soldier.request.BaseGetRequest;
import com.insigma.business.qrcode.soldier.request.SoldierOuterLoginAccountBSearcher;
import com.insigma.business.qrcode.soldier.request.SoldierOuterLoginAccountInsertRequest;
import com.insigma.business.qrcode.soldier.request.SoldierOuterLoginAccountSearchRequest;
import com.insigma.business.qrcode.soldier.service.SoldierOuterLoginAccountService;
import com.insigma.business.qrcode.soldier._provider.BaseSoldierOuterLoginAccountProvider;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@Service("soldierOuterLoginAccountService")

public class SoldierOuterLoginAccountServiceImpl implements SoldierOuterLoginAccountService {

    @Autowired(required = false)
    private SoldierOuterLoginAccountDao soldierOuterLoginAccountDao;
    @Autowired(required = false)
    private SequenceGenerator sequenceGenerator;


    @Override
    public SoldierOuterLoginAccountDO getByOuterSysTypeAndUserId(Integer outerSystemType, String outerSystemAccountId) {
        return soldierOuterLoginAccountDao.getByOuterSysTypeAndUserId(outerSystemType, outerSystemAccountId);
    }

    @Override
    public SoldierOuterLoginAccountDO getByIdCardNo(String idCardNo) {
        return soldierOuterLoginAccountDao.getByIdCardNo(idCardNo);
    }

    @Override
    public SoldierOuterLoginAccountDO getByZlbId(String outerZlbAccountId) {
        return soldierOuterLoginAccountDao.getByZlbId(outerZlbAccountId);
    }

    @Override
    public Integer delete(String id, String modifierType, String modifierId) {
        return soldierOuterLoginAccountDao.delete(id,modifierType,modifierId);
    }

    @Override
    public Integer update(SoldierOuterLoginAccountDO soldierOuterLoginAccount) {
        return soldierOuterLoginAccountDao.update(soldierOuterLoginAccount);

    }

    @Override
    public Integer insert(SoldierOuterLoginAccountDO soldierOuterLoginAccount) {
        return soldierOuterLoginAccountDao.insert(soldierOuterLoginAccount);
    }

    @Override
    public List<SoldierOuterLoginAccountDO> search(SoldierOuterLoginAccountBSearcher searcher) {
        return soldierOuterLoginAccountDao.search(searcher);
    }

    @Override
    public Boolean updateRealNameIfMobileExisted(String soldierId, String mobile, String userName) {
    //    Boolean dto = baseSoldierOuterLoginAccountProvider.updateRealNameIfMobileExisted(soldierId, mobile, userName).getDto();
        return true;
    }

    @Override
    public SoldierOuterLoginAccountDO getAccountDtoBySoldierId(String soldierId) {
        return soldierOuterLoginAccountDao.getAccountDtoBySoldierId(soldierId);
    }

    @Override
    public SoldierOuterLoginAccountDO get(String id) {
        return soldierOuterLoginAccountDao.get(id);
    }

    private SoldierOuterLoginAccountDO convertDtoToDo(SoldierOuterLoginAccountDTO dto) {
        if (dto != null) {
            SoldierOuterLoginAccountDO soldierDO = new SoldierOuterLoginAccountDO();
            BeanUtils.copyProperties(dto, soldierDO);
            return soldierDO;
        } else {
            return null;
        }
    }
}
